package cn.ml.gaoJi.jiHe;

import java.util.*;

public class PlayPoker {
    public static void main(String[] args) {
        HashMap<Integer, String> hm = new HashMap<Integer, String>();
        ArrayList<Integer> array = new ArrayList<Integer>();
//        color数组装牌的花色
        String[] color = {"♦","♣","❤","♠"};
//        num数组装牌的大小
        String[] num = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        int index = 0;
//        外层循环是牌的大小，内层循环是花色
        for (String num1 : num) {
            for (String color1 : color) {
                hm.put(index,color1+num1);
                array.add(index);
                index++;
            }
        }
        hm.put(index,"小王");
        array.add(index);
        index++;
        hm.put(index,"大王");
        array.add(index);
//        洗牌操作，掉用Collections工具类里面的shuffle方法
        Collections.shuffle(array);
//        用TreeSet来实现对牌的排序
        TreeSet<Integer> player1 = new TreeSet<Integer>();
        TreeSet<Integer> player2 = new TreeSet<Integer>();
        TreeSet<Integer> player3 = new TreeSet<Integer>();
        TreeSet<Integer> dp = new TreeSet<Integer>();
        for (int i = 0; i < array.size() ; i++) {
            int s = array.get(i);
//            最后三张就是底牌
            if (i >= array.size()-3) {
                dp.add(s);
            }else if (i % 3 == 0) {
                player1.add(s);
            }else if (i % 3 == 1) {
                player2.add(s);
            }else if (i % 3 == 2) {
                player3.add(s);
            }
        }

        lookPoker("蔡徐村",player1,hm);
        lookPoker("苏珊",player2,hm);
        lookPoker("小黑子",player3,hm);
        lookPoker("底牌",dp,hm);
    }
    public static void lookPoker(String name,TreeSet<Integer> t,HashMap<Integer,String> hm) {
        System.out.println(name+"的牌是：");
        for (Integer key : t) {
            String poker = hm.get(key);
            System.out.print(poker + " ");
        }
        System.out.println();
    }
}

